package main

import (
	"github.com/gin-gonic/gin"
	"go_code/gin-blog/controller"
	"go_code/gin-blog/dao/db"
	"log"
)

func main() {
	err := db.InitDb()
	if err != nil {
		log.Fatalf("mysql start faild,err:%s", err)
	}
	r := gin.Default()
	r.Static("/static", "./static")
	r.LoadHTMLGlob("views/*")
	r.GET("/", controller.IndexHandler)
	r.GET("/article/detail/", controller.GetArticleDetils)
	r.POST("/comment/submit/", controller.PostComment())
	r.GET("/category/", controller.GetArticleByCategoryId)
	//去添加文章界面
	r.GET("/article/new", controller.ArticleNew)
	//添加图书
	r.POST("/article/submit", controller.AddArticle)

	//去留言界面
	r.GET("/leave/new", controller.LeaveNew)
	//留言
	r.POST("/leave/submit", controller.AddLeave)

	//about me
	r.GET("/about/me", controller.About)
	log.Fatal(r.Run(":5254"))
}
